package com.chaos.meta.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.sql.Timestamp;
import java.util.Collection;

/**
 * @author naicha
 */
@Data
@TableName("chaos_user")
public class User implements UserDetails {
	private static final long serialVersionUID = 1L;

	@TableId("user_id")
	private Long userId;

	@TableField("user_name")
	private String userName;

	@TableField("password")
	private String password;

	@TableField("email")
	private String email;

	@TableField("create_time")
	private Timestamp createTime;

	@TableField("update_time")
	private Timestamp updateTime;

	@TableField("role_id")
	private Integer roleId;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * 以下为spring security可选配置字段
	 */
	private Collection<? extends GrantedAuthority> authorities;

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities()
	{
		return this.authorities;
	}

	@Override
	public String getPassword() {
		return this.password;
	}

	@Override
	public String getUsername() {
		return this.userName;
	}

	@Override
	public boolean isAccountNonExpired() {
		return false;
	}

	@Override
	public boolean isAccountNonLocked() {
		return false;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return false;
	}

	@Override
	public boolean isEnabled() {
		return false;
	}
}
